package cn.zch.test;
import cn.zch.test.imgocr.ImgOcr;
import cn.zch.test.wordsocr.WordsOcr;

import java.io.File;
import java.util.Scanner;
/**
 * @author zch
 */
public class Main {
	public static void main(String[] args) {
		goOcr();
	}
	/**
	 * goOcr
	 */
	private static void goOcr() {
		boolean stop = false;
		while (!stop) {
			System.out.println("请输入您想要识别的图片地址:");
			Scanner sc = new Scanner(System.in);
			String imgPath = sc.nextLine();
			File file = new File(imgPath);
			if (file.exists()) {
				System.out.println("请输入您想要识别的内容:");
				System.out.println("1:识别图片中的植物");
				System.out.println("2:识别图片中的文字");
				int methodChoice = sc.nextInt();
				if (methodChoice == 1) {
					ImgOcr.plantDetect(imgPath);
				}
				else {
					System.out.println("3:请输入结果输出类型:1 全部输出 2 json格式 3 只输出识别信息");
					int outLineType = sc.nextInt();
					WordsOcr.basicGeneral(imgPath, outLineType);
				}
			}
			else {
				System.out.println("文件不存在!");
			}
			System.out.println("4:退出吗？键入 n 不退出，其它字符 退出");
			Scanner scStr = new Scanner(System.in);
			String exitStr = scStr.nextLine();
			stop = !"n".equals(exitStr);
		}
	}
}
